package com.baicaoyuan.web.common;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 功能描述：邀请码
 *
 * @author 罗富祥
 * 创建时间： 2018/8/17
 */

@Data
@Component
@ConfigurationProperties(prefix = "invitation")
public class InvitationCodeUtil {

    private String length;
    private String prefix;

    public String generate_invitation_code(Long id) {
        Objects.requireNonNull(length);
        String format = "%0" + length + "d";
        String result = prefix + String.format(format, id);
        return result;
    }
}
